package com.efamily.ewallet.client;

import com.efamily.ewallet.client.account.bean.AccountBean;
import com.efamily.ewallet.client.expense.widget.ExpenseGridWidget;
import com.efamily.ewallet.client.profit.widget.ProfitGridWidget;
import com.extjs.gxt.ui.client.widget.Composite;
import com.extjs.gxt.ui.client.widget.TabItem;
import com.extjs.gxt.ui.client.widget.TabPanel;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;

public class ExpensesAndProfitsWidget extends Composite {
	private TabPanel mainTabPanel = new TabPanel();
	private AccountBean accountBean = new AccountBean();

	public ExpensesAndProfitsWidget(AccountBean accountBean) {
		this.accountBean = accountBean;
		addExpenseWidget();
		addProfitWidget();
		initComponent(mainTabPanel);
	}

	private void addExpenseWidget() {
		TabItem expenseTab = new TabItem();
		expenseTab.setLayout(new FitLayout());
		ExpenseGridWidget expenseWidget = new ExpenseGridWidget(accountBean);
		expenseTab.add(expenseWidget);
		expenseTab.setText("Expenses");
		mainTabPanel.add(expenseTab);
	}

	private void addProfitWidget() {
		TabItem profitTab = new TabItem();
		profitTab.setLayout(new FitLayout());
		ProfitGridWidget profitWidget = new ProfitGridWidget(accountBean);
		profitTab.add(profitWidget);
		profitTab.setText("Profits");
		mainTabPanel.add(profitTab);

	}

}
